const crypto = require('crypto');
const fs = require('fs');

module.exports = {
  md5(buffer) {
    let obj = crypto.createHash('md5');
    obj.update(buffer);
    return obj.digest('hex')
  },
  /**
   * 删除本地文件
   * @param {路径} path 
   */
  unlink(path) {
    return new Promise((resolve, reject) => {
      fs.unlink(path, (err) => {
        if (err) {
          reject(err);
        } else {
          resolve();
        }
      });
    });

  }
}